package com.liujun.spring4.demo.aop.pointcut.composablepointcut;

import com.liujun.spring4.demo.aop.pointcut.flowpointcut.WaiterDelegate;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.ComposablePointcut;
import org.springframework.aop.support.ControlFlowPointcut;
import org.springframework.aop.support.NameMatchMethodPointcut;

/**
 * 进行复合节点的配制操作
 *
 * @author liujun
 * @version 0.0.1
 * @date 2018/09/27
 */
public class GreetingComposablePointcut {

  public Pointcut getIntersectionPointcut() {
    ComposablePointcut cp = new ComposablePointcut();

    // 指定流程切点
    Pointcut pt1 = new ControlFlowPointcut(WaiterDelegate.class, "server");

    // 方法切点
    NameMatchMethodPointcut pt2 = new NameMatchMethodPointcut();
    pt2.addMethodName("greetTo");

    return cp.intersection(pt1).intersection((Pointcut) pt2);
  }
}
